package com.jlcloud.core.oauth2.handler;

import com.jlcloud.core.oauth2.provider.OAuth2Request;
import com.jlcloud.core.oauth2.provider.OAuth2Validation;
import com.jlcloud.core.oauth2.service.OAuth2User;

/**
 * OAuth2AuthorizationHandler
 *
 * @author By: JlCloud <br>
 * @Package: com.jlcloud <br>
 * @CreateTime: 2024-12-03 21:45 <br>
 * @Copyright: 2021 www.jilianjituan.com Inc. All rights reserved. <br>
 * @Caution 注意：本内容仅限于冀联人力集团内部传阅，禁止外泄以及用于其他的商业目的 <br>
 */
public interface AuthorizationHandler {

	/**
	 * 认证前校验
	 *
	 * @param request 请求信息
	 * @return boolean
	 */
	OAuth2Validation preValidation(OAuth2Request request);

	/**
	 * 认证前失败回调
	 *
	 * @param validation 失败信息
	 */
	void preFailure(OAuth2Request request, OAuth2Validation validation);

	/**
	 * 认证校验
	 *
	 * @param user    用户信息
	 * @param request 请求信息
	 * @return boolean
	 */
	OAuth2Validation authValidation(OAuth2User user, OAuth2Request request);

	/**
	 * 认证成功回调
	 *
	 * @param user 用户信息
	 */
	void authSuccessful(OAuth2User user, OAuth2Request request);

	/**
	 * 认证失败回调
	 *
	 * @param user       用户信息
	 * @param validation 失败信息
	 */
	void authFailure(OAuth2User user, OAuth2Request request, OAuth2Validation validation);
}
